package com.actionsky.action;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.actionsky.dao.RssItemDAO;
import com.actionsky.entity.RssItem;

public class KnowledgeBaseAction extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private static final int LIST_COUNT = 20;
	List<RssItem> rssList = null;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		rssList = RssItemDAO.findChangedDocuments(LIST_COUNT);
		if (rssList != null){
			request.getSession().setAttribute("error", false);
			request.getSession().setAttribute("changedList", rssList);
			response.sendRedirect("index.jsp");
		}else{
			request.getSession().setAttribute("error", true);
		}
	}
	public void init() throws ServletException {
	}
	public void destroy() {
		super.destroy(); 
	}
}
